//Wed Mar  9 15:12:18 CST 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class FoxSequence
{
public:

    string isValid(vector <int> seq)
    {
        int sz = seq.size();
        if (sz < 5) return "NO";
        vector<int> v;
        for (int i = 1; i < sz; i++)
        {
            v.push_back(seq[i] - seq[i - 1]);
        }
        for (int i = 0; i < v.size(); i++)
            cout << v[i] << endl;
        cout << endl;
        vector<int> diff;
        diff.push_back(v[0]);
        for (int i = 1; i < v.size(); i++)
        {
            if (v[i] != v[i - 1])
                diff.push_back(v[i]);
        }
        for (int i = 0; i < diff.size(); i++)
            cout << diff[i] << endl;
        if (diff.size() == 5)
        {
            if (diff[0] > 0 && diff[1] < 0 && diff[2] == 0 && diff[3] > 0 && diff[4] < 0)
                return "YES";
            return "NO";
        }
        if (diff.size() == 4)
        {
            if (diff[0] > 0 && diff[1] < 0 && diff[2] > 0 && diff[3] < 0)
                return "YES";
            return "NO";
        }
        return "NO";
    }
};
